/**
 * @param {number[]} nums1
 * @param {number[]} nums2
 * @return {number}
 */
var findMedianSortedArrays = function(nums1, nums2) {
    let i =0,j=0
    let arr =[]
    let len1 = nums1.length, len2 = nums2.length;
    while(i<len1&&j<len2){
        if(nums1[i]<=nums2[j]){
            arr.push(nums1[i++])          
        }else{
            arr.push(nums2[j++])
        }
    }
    console.log('arr',arr)
    if(i!==len1){
        arr = arr.concat(nums1.slice(i))
    }
    if(j!==len2){
        arr = arr.concat(nums2.slice(j))
    }
    console.log('arr',arr)

    if(arr.length%2===0){
        return (arr[arr.length/2-1]+arr[arr.length/2])/2
    }else{
        return arr[Math.floor(arr.length/2)]
    }
};

console.log(findMedianSortedArrays([1,3,5,7],[2,4,6,8,10,12]))